img = imread('/image/S/jpg/Tp_S_NNN_M_B_arc10129_arc10129_11893.jpg');
gray = rgb2gray(img);
scaled = double(gray / 256);
[frames,descriptors] = sift(scaled);
%sort by theta
[frames, ind] = sortrows(frames', 4);
frames = frames';
descriptors = descriptors(:, ind);

[frames2, ind2] = sortrows(frames', 3);
frames2 = frames2';
descriptors2 = descriptors(:, ind2);

%plotsiftframe(frames)
%plotsiftdescriptor(descriptors, frames)
%q = frames(:,1:end-1)-frames(:,2:end);
%v = min(abs(q(4,:)));

[features, pos] = extractOverlayBlock(gray, 32, @f9); 
match = findMatch(features, pos, @matchL1);
%for i = 1:length(match)
%    dispBlock(img, pos, match{i}(1), match{i}(2));
%    pause(0.5);
%end
